package org.riki.red5server.acs.clientApplicationBASE.clientApplication.RussianBox;

import org.riki.red5server.acs.clientApplicationBASE.clientApplication.RussianBox.datetype.player;
import org.riki.red5server.acs.dataSet.User;

public class PlayerItem extends player
{
	public	boolean	canCreatedRoom		=	true;
	public	int		currentGameRoomId	=	-1;
	
	private	byte	maxpower			=	50;
	
	public PlayerItem(User u)
	{
		this.playerId      = u.imvu_id;
		this.playerName    = u.imvu_name;
		this.playerNick    = u.imvu_nick;
		this.playerHeadImg = u.imvu_face;
		this.isGirl        = u.imvu_isgirl;
	}
	
	public void clearLine(byte lines,byte[] cDate)
	{
		if(lines == 1)
		{
			power+=1;
			this.playerScore+=100;
		}
		if(lines == 2)
		{
			power+=3;
			this.playerScore+=300;
		}
		if(lines == 3)
		{
			power+=7;
			this.playerScore+=700;
		}
		if(lines == 4)
		{
			power+=15;
			this.playerScore+=1500;
		}
				
		int	count1		=	0;
		int	count2		=	0;
		
		for(int i = 0 ; i < 200 ; i ++)
		{
			count1+=this.gameDate[i];
		}
		
		for(int i = 0 ; i < 200 ; i ++)
		{
			count2+=cDate[i];
		}
		
		count2+=lines*10;
		
		this.playerScore+=(count2-count1)*5;
		
		this.gameDate	=	cDate;		
	}
	
	public boolean isAttack()
	{
		if(power>=maxpower)
		{
			power-=maxpower;
			return true;
		}
		return false;
	}
	
	public boolean isOver()
	{
		for(int i = 0 ; i < 10 ; i ++)
		{
			if(this.gameDate[i]>0)
			{
				return true;
			}
		}
		return false;
	}
	
	public player toPlayer()
	{
		player returnPlayer            = new player();
		returnPlayer.playerId          = this.playerId;
		returnPlayer.playerName        = this.playerName;
		returnPlayer.playerNick        = this.playerNick;
		returnPlayer.isGirl            = this.isGirl;
		returnPlayer.isReady           = this.isReady;
		returnPlayer.playerSeatId      = this.playerSeatId;
		returnPlayer.currentGameRoomId = this.currentGameRoomId;
		return returnPlayer;		
	}
}
